package com.hhsjtest.scaffold;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

import androidx.annotation.NonNull;

import com.hhsj.design.pullableview.ability.IPullAble;
import com.hhsj.design.pullableview.listview.RefreshListViewPro;
import com.hhsjtest.scaffold.abs.ScaffoldView;


public class ListScaffoldView extends ScaffoldView<RefreshListViewPro> {

    private boolean isDebug = false;

    private LinearLayout mainContentView;
    private IPullAble.PullAbleListener mListener;

    public ListScaffoldView(Context context) {
        this(context, null);
    }

    public ListScaffoldView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ListScaffoldView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mainContentView = new LinearLayout(getContext());
        mainContentView.setId(R.id.scaffold_contentview);
        mainContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        mainContentView.setOrientation(LinearLayout.VERTICAL);
        contentScrollView.addHeaderView(mainContentView);
    }


    @Override
    protected void scrollToTop() {
        contentScrollView.setSelection(0);
    }

    public void setMainContentView(@NonNull View view) {
        contentScrollView.addHeaderView(view);
    }

    public ListView getListView() {
        return contentScrollView;
    }

}
